package com.ccys.cms.controller.administrator;

import com.ccys.cms.service.administrator.TblUParcelSettingWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblUParcelPostalCodeExclusionDTO;
import com.ccys.db.dto.administrator.TblUParcelSettingDTO;
import com.ccys.db.entity.TblUParcelSetting;
import com.ccys.db.vo.administrator.TblUParcelPostalCodeExclusionWebVO;
import com.ccys.db.vo.administrator.TblUParcelSettingWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "系统设置-UParcel settings")
@RequestMapping("administrator")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class UParcelSettingWebController {

    @Autowired
    private TblUParcelSettingWebService tblUParcelSettingWebService;




    @GetMapping("uParcelSetting")
    @ApiOperation("获取UParcel settings（只有一条数据）")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "postalCode", value = "postalCode", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),

        @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblUParcelSettingWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblUParcelSettingDTO dto) {
        return this.tblUParcelSettingWebService.listObjectsCms(request, response, dto);
    }


    @PutMapping("uParcelSetting")
    @ApiOperation("编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "code", value = "code", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "standardOrderCutOffTime", value = "standardOrderCutOffTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "standardOrderTimeBuffer", value = "standardOrderTimeBuffer", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "expressOrderCutOffTime", value = "expressOrderCutOffTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "accessToken", value = "accessToken", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "expressTypeId", value = "expressTypeId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "standardTypeId", value = "standardTypeId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "expressTypeName", value = "expressTypeName", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "standardTypeName", value = "standardTypeName", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblUParcelSetting entity) {
        return this.tblUParcelSettingWebService.change(request, response, entity);
    }



}